package com.focusai.efairy.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.focusai.efairy.R;
import com.focusai.efairy.model.manager.CacheManager;
import com.focusai.efairy.ui.activity.announce.AnnounceListActivity;
import com.focusai.efairy.ui.activity.maintain.MaintainRecordeListActivity;
import com.focusai.efairy.ui.activity.project.ProjectListActivity;
import com.focusai.efairy.ui.activity.warn.AlarmListActivity;
import com.focusai.efairy.ui.base.BaseFragment;

/**
 * Created by luo_guangwen on 2017/7/11.
 */

public class AppFragment extends BaseFragment implements View.OnClickListener {

    public AppFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_app, container, false);
        initView(view);
        return view;
    }

    @Override
    protected void initView(View view) {
        findView(view, R.id.item_report_ll).setOnClickListener(this);
        findView(view, R.id.item_notice_ll).setOnClickListener(this);
        findView(view, R.id.item_manage_ll).setOnClickListener(this);
        findView(view, R.id.item_record_ll).setOnClickListener(this);
        findView(view, R.id.item_pay_ll).setOnClickListener(this);
        findView(view, R.id.item_alarm_ll).setOnClickListener(this);
        if (4 == CacheManager.getUserRoleLevel()){
            findView(view, R.id.item_pay_place).setVisibility(View.INVISIBLE);
            findView(view,R.id.item_manage_ll).setVisibility(View.GONE);
        }else {
            findView(view, R.id.item_pay_place).setVisibility(View.GONE);
            findView(view,R.id.item_manage_ll).setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.item_report_ll:
                intent = new Intent(getContext(), ProjectListActivity.class);
                intent.putExtra(ProjectFragment.OPEN_TYPE, ProjectFragment.OPEN_TYPE_REPORT);
                startActivity(intent);
//                showToast("功能正在开发中..");

                break;
            case R.id.item_notice_ll:
                intent = new Intent(getContext(), AnnounceListActivity.class);
                startActivity(intent);
//                showToast("功能正在开发中..");
                break;
            case R.id.item_manage_ll:
//                showToast("功能正在开发中..");
                intent = new Intent(getContext(), ProjectListActivity.class);
                intent.putExtra(ProjectFragment.OPEN_TYPE, ProjectFragment.OPEN_TYPE_PROJECT_MANAGE);
                startActivity(intent);
                break;
            case R.id.item_record_ll:
                intent = new Intent(getContext(), MaintainRecordeListActivity.class);
                startActivity(intent);
                break;
            case R.id.item_pay_ll:
                showToast("功能正在开发中..");
                break;
            case R.id.item_alarm_ll:
                intent = new Intent(getContext(), AlarmListActivity.class);
                startActivity(intent);
                break;

            default:
                break;
        }
    }
}
